#ifndef __QLIST_H__
#define __QLIST_H__

#define ERROR_NO 1
#define OK_NO 0
#define DATA_SIZE 64

typedef struct QNode
{
    void *data;
    struct QNode *next;
    size_t data_len;
} QNode;

extern QNode *create_node(void *data, size_t data_len);
extern void insert_head(QNode **head, void *data, size_t data_len);
extern void insert_tail(QNode **head, void *data, size_t data_len);
extern void delete_node(QNode **head, void *key, int (*cmp)(void *, void *), void (*free_func)(void *));
extern void free_node_data(void *data);
extern void free_list(QNode *head, void (*free_func)(void *));
extern QNode *find_node(QNode *head, void *key, int (*cmp)(void *, void *));
extern void print_list(QNode *head, void (*print_func)(QNode *));
extern void insert_node_to_head(QNode **head, QNode* new_node, void *data, size_t data_len);
extern void insert_node_to_tail(QNode **head, QNode* new_node, void *data, size_t data_len);
extern QNode *pick_tail_node(QNode **head, int must_has_data_flag);
extern int list_node_count(QNode *head);

#endif